<?php
namespace Admin\Model;

use Think\Model;

/**
* Created by hanquan.
* User Adminstrator
* Date 2017/3/26
* Time 21:29
* VersionModel 手机型号类
*/
class VersionModel extends Model
{

	private $Version = null;

	function __construct(){
		$this->Version = M('Version');
	}
	/**
     * 获取手机型号列表
     */
	public function get_version($bid){

		$condition['bid'] = $bid;
		$condition['v_status'] = 1;
		return $this->Version->field('vid,v_imgurl,v_name')->where($condition)->select();
	}

	/**
     * 获取手机型号
     */
	public function get_version_info($vid){
		$condition['vid'] = $vid;
		return $this->Version->where($condition)->find();
	}

	/**
     * 获取回收费用
     */
	public function get_recycle_cost($vid){
		$condition['vid'] = $vid;
		return $this->Version->field('v_max_price,v_min_price')->where($condition)->find();
	}

	/**
     * 插入或修改手机型号
     * @data 提交手机型号的数据
     * @bid 手机型号id
     */
	public function set_version($data,$vid=FALSE){

		if(!$vid){
			return $this->Version->add($data);
		}else{
			$condition['vid'] = $vid;
			return $this->Version->where($condition)->save($data);
		}
	}
}